package com.example.avmanagerweb.encryption;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import org.junit.jupiter.api.Test;

import java.util.Map;

public class EncryptionMD5 {

    @Test
    public void Encryp() {
        String str = "{\"userAcc\":\"jwdadmin01\",\"key\":\"ORTSY\",\"userpwd\":\"iujThWqoLrmzOKoP4/zxcLmc0125Y4YkH57XU6zJWiXhiCaiyJfX1m/niM+l91Fi\"}";
        Map<String, String> map = JSON.parseObject(str, new TypeReference<Map<String, String>>() {});
        System.out.println(map.toString());
        //1.查询秘钥   数据库查询：
            //1-1 key - privateKey
        String privateKey = "TYSEOPS";
        //2.账号和key  匹配
        {

        }
        //加密解密
//        String tyseops = MD5Util.oneEncrypt(map, privateKey );
//        System.out.println(tyseops);


    }

    @Test
    public void Encryp2() throws Exception {
//        String str = "{\"key\":\"KEY_YFEIA\",\"userAcc\":\"jwdadmin01\",\"userpwd\":\"iujThWqoLrmzOKoP4/zxcLmc0125Y4YkH57XU6zJWiXhiCaiyJfX1m/niM+l91Fi\"}";
//        String str = "{\"userAcc\":\"sccs001\",\"userpwd\":\"12kSEDmuyOwjdEaOZKljPnhY6mAoFLz1pdhVtdihP/ThiCaiyJfX1m/niM+l91Fi\",\"key\":\"KEY_YFEIA\"}";
        String str = "{\"userAcc\":\"jwdadmin02\",\"userpwd\":\"iujThWqoLrmzOKoP4/zxcLmc0125Y4YkH57XU6zJWiXhiCaiyJfX1m/niM+l91Fi\",\"key\":\"KEY_YFEIA\"}";
        //1.查询秘钥   数据库查询：
        //1-1 key - privateKey
        String privateKey = "JWD_OLOUSH%$#&98";
        if( !(privateKey.length() !=16 || privateKey.length() !=24 || privateKey.length() !=32) ){
            System.out.println("16, 24, or 32 bytes key");
            return;
        }
        //2.账号和key  匹配
        {

        }
        //加密解密
        String tyseops = com.example.avmanagerweb.Utils.EncryptionUtil.AESUtil.encrypt(str,privateKey);
        System.out.println(tyseops);
        String decrypt = AESUtil.decrypt(tyseops, privateKey );
        System.out.println(decrypt);



    }

    @Test
    public void Encryp3() throws Exception {
        String MD5 = "JWD88888";
        String encrypt = AESUtil.encrypt(MD5,"JWD-TIWN$#JNGSS9");
        System.out.println(encrypt);

    }

}
